package main

import (
	"flag"
	"fmt"
	"log"
	"time"

	"github.com/ChuranNeko/gginx/pkg/http3"
)

func main() {
	url := flag.String("url", "https://localhost:8443", "测试目标URL")
	conns := flag.Int("connections", 100, "并发连接数")
	reqPerConn := flag.Int("requests", 1000, "每个连接的请求数")
	duration := flag.Duration("duration", 30*time.Second, "测试持续时间")
	payload := flag.Int("payload", 1024, "请求负载大小(bytes)")

	flag.Parse()

	config := http3.BenchmarkConfig{
		URL:            *url,
		Connections:    *conns,
		RequestsPerCon: *reqPerConn,
		Duration:       *duration,
		PayloadSize:    *payload,
	}

	fmt.Printf("开始HTTP/3性能测试:\nURL: %s\n并发数: %d\n每连接请求数: %d\n持续时间: %v\n\n",
		config.URL, config.Connections, config.RequestsPerCon, config.Duration)

	result, err := http3.RunBenchmark(config)
	if err != nil {
		log.Fatalf("测试失败: %v", err)
	}

	fmt.Println(result)
}
